package com.imooc.miaosha.service;

import com.imooc.miaosha.dao.UserMapper;
import com.imooc.miaosha.domain.MiaoShaUser;
import com.imooc.miaosha.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User selectById(int id){
        return userMapper.selectById(id);
    }

    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    //事务
    @Transactional
    public boolean tx(){
        User user1 = new User(2,"222");
        userMapper.insertUser(user1);

        User user2 = new User(3,"333");
        userMapper.insertUser(user2);

        return true;
    }

}
